/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package edu.pku.sei.ocl.adapter.xmlecore.impl;

import edu.pku.sei.ocl.adapter.xmlecore.EXMLDocument;
import edu.pku.sei.ocl.adapter.xmlecore.EXMLElement;
import edu.pku.sei.ocl.adapter.xmlecore.XmlecoreFactory;
import edu.pku.sei.ocl.adapter.xmlecore.XmlecorePackage;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.w3c.dom.*;
/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>EXML Document</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link edu.pku.sei.ocl.adapter.xmlecore.impl.EXMLDocumentImpl#getEncoding <em>Encoding</em>}</li>
 *   <li>{@link edu.pku.sei.ocl.adapter.xmlecore.impl.EXMLDocumentImpl#getXmlVersion <em>Xml Version</em>}</li>
 *   <li>{@link edu.pku.sei.ocl.adapter.xmlecore.impl.EXMLDocumentImpl#getDocumentElement <em>Document Element</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class EXMLDocumentImpl extends EXMLNodeImpl implements EXMLDocument {
	/**
	 * The default value of the '{@link #getEncoding() <em>Encoding</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getEncoding()
	 * @generated
	 * @ordered
	 */
	protected static final String ENCODING_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getEncoding() <em>Encoding</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getEncoding()
	 * @generated
	 * @ordered
	 */
	protected String encoding = ENCODING_EDEFAULT;

	/**
	 * The default value of the '{@link #getXmlVersion() <em>Xml Version</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getXmlVersion()
	 * @generated
	 * @ordered
	 */
	protected static final String XML_VERSION_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getXmlVersion() <em>Xml Version</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getXmlVersion()
	 * @generated
	 * @ordered
	 */
	protected String xmlVersion = XML_VERSION_EDEFAULT;

	/**
	 * The cached value of the '{@link #getDocumentElement() <em>Document Element</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDocumentElement()
	 * @generated
	 * @ordered
	 */
	protected EXMLElement documentElement;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected EXMLDocumentImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return XmlecorePackage.Literals.EXML_DOCUMENT;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getEncoding() {
		return encoding;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setEncoding(String newEncoding) {
		String oldEncoding = encoding;
		encoding = newEncoding;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, XmlecorePackage.EXML_DOCUMENT__ENCODING, oldEncoding, encoding));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getXmlVersion() {
		return xmlVersion;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setXmlVersion(String newXmlVersion) {
		String oldXmlVersion = xmlVersion;
		xmlVersion = newXmlVersion;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, XmlecorePackage.EXML_DOCUMENT__XML_VERSION, oldXmlVersion, xmlVersion));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EXMLElement getDocumentElement() {
		if (documentElement != null && documentElement.eIsProxy()) {
			InternalEObject oldDocumentElement = (InternalEObject)documentElement;
			documentElement = (EXMLElement)eResolveProxy(oldDocumentElement);
			if (documentElement != oldDocumentElement) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, XmlecorePackage.EXML_DOCUMENT__DOCUMENT_ELEMENT, oldDocumentElement, documentElement));
			}
		}
		return documentElement;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EXMLElement basicGetDocumentElement() {
		return documentElement;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setDocumentElement(EXMLElement newDocumentElement) {
		EXMLElement oldDocumentElement = documentElement;
		documentElement = newDocumentElement;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, XmlecorePackage.EXML_DOCUMENT__DOCUMENT_ELEMENT, oldDocumentElement, documentElement));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case XmlecorePackage.EXML_DOCUMENT__ENCODING:
				return getEncoding();
			case XmlecorePackage.EXML_DOCUMENT__XML_VERSION:
				return getXmlVersion();
			case XmlecorePackage.EXML_DOCUMENT__DOCUMENT_ELEMENT:
				if (resolve) return getDocumentElement();
				return basicGetDocumentElement();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case XmlecorePackage.EXML_DOCUMENT__ENCODING:
				setEncoding((String)newValue);
				return;
			case XmlecorePackage.EXML_DOCUMENT__XML_VERSION:
				setXmlVersion((String)newValue);
				return;
			case XmlecorePackage.EXML_DOCUMENT__DOCUMENT_ELEMENT:
				setDocumentElement((EXMLElement)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case XmlecorePackage.EXML_DOCUMENT__ENCODING:
				setEncoding(ENCODING_EDEFAULT);
				return;
			case XmlecorePackage.EXML_DOCUMENT__XML_VERSION:
				setXmlVersion(XML_VERSION_EDEFAULT);
				return;
			case XmlecorePackage.EXML_DOCUMENT__DOCUMENT_ELEMENT:
				setDocumentElement((EXMLElement)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case XmlecorePackage.EXML_DOCUMENT__ENCODING:
				return ENCODING_EDEFAULT == null ? encoding != null : !ENCODING_EDEFAULT.equals(encoding);
			case XmlecorePackage.EXML_DOCUMENT__XML_VERSION:
				return XML_VERSION_EDEFAULT == null ? xmlVersion != null : !XML_VERSION_EDEFAULT.equals(xmlVersion);
			case XmlecorePackage.EXML_DOCUMENT__DOCUMENT_ELEMENT:
				return documentElement != null;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (encoding: ");
		result.append(encoding);
		result.append(", xmlVersion: ");
		result.append(xmlVersion);
		result.append(')');
		return result.toString();
	}

	@Override
	public String getNodeName() {
		return "#document";
	}

} //EXMLDocumentImpl
